arr=[
{"name":"red"      ,"color":"#ef5350"},
{"name":"pink"     ,"color":"#e91e63"},
{"name":"purple"   ,"color":"#ab47bc"},
{"name":"blue"     ,"color":"#2196f3"},
{"name":"green"    ,"color":"#4caf50"},
{"name":"orange"   ,"color":"#fb8c00"},
{"name":"brown"    ,"color":"#795548"},
{"name":"blue-grey","color":"#546e7a"},
{"name":"white"    ,"color":"#ffffff"},
]

for(var i=0;i<arr.length;i++){
	document.getElementById("color").innerHTML
	+="<button style='border-radius: 5px;border:1px;margin:5px;padding:10px;width:100px;height:50px;background-color:"+arr[i].color+";display: inline-block;color:"+(arr[i].name=='white'?'#333':'#fff')+"' class='color-button' onclick='updcol(\""+arr[i].name+"\")'>"+arr[i].name+"</button>";
}
$(document).ready(function(){
	if(hitokoto=='true')
	$('#enable-hitokoto').prop('checked',hitokoto);
	$("#enable-hitokoto").click(function(){
		//console.log("kk");
		if($("#enable-hitokoto").is(':checked')){
			$('#hitokoto').css('display','block');
			localStorage.setItem('hitokoto',true);
		}else{
			$('#hitokoto').css('display','none');
			localStorage.setItem('hitokoto',false);
		}
	});

	if(toc=='true')
	$('#enable-toc').prop('checked',hitokoto);
	$("#enable-toc").click(function(){
		//console.log("kk");
		if($("#enable-toc").is(':checked'))
			localStorage.setItem('toc',true);
		else
			localStorage.setItem('toc',false);
	});
	$("#opacity").slider({"min":0,"max":1,"step":0.02,"value":opacity});
	$("#opacityVal").text(opacity);
	$("#opacity").on("slide", function(slideEvt) {
		$("#opacityVal").text(slideEvt.value);
		$(".container .card ").css('background-color',"rgba(252,252,252,"+slideEvt.value+")");
		$(".table-striped>tbody>tr:nth-of-type(odd)").css('background-color',"rgba(252,252,252,"+slideEvt.value+")");
		$(".panel-heading ").css('background-color',"rgba(252,252,252,"+Math.min(1.0,slideEvt.value+0.2)+")");
		localStorage.setItem('opacity',slideEvt.value);
	});
	
	if(background=="false"){
		$('#enable-background').prop("checked",false);
		$('#background').prop("disabled",true);
		$('#background').prop("value","启用以输入");
	}else{
		$('#enable-background').prop("checked",true);
		$('#background').prop("disabled",false);
		$('#background').prop("value",background);
	}
	$("#enable-background").click(function(){
		//console.log("kk");
		if($("#enable-background").is(':checked')){
			$('#background').prop("disabled",false);
			$('#background').prop("value","");
		}else{
			$('#background').prop("disabled",true);
			$('#background').prop("value","启用以输入");
			localStorage.setItem('background',"false");
			$('html').css('background',"#eee");
		}
	});
	$("#background").change(function(){
		console.log($("#background").prop("value"));
		$('html').css('background',"url("+$("#background").prop("value")+") 50% 50% / cover no-repeat fixed");
		localStorage.setItem('background',$("#background").prop("value"));
	})

	if(mouse=='true')
	$('#enable-mouse').prop('checked',mouse);
	$("#enable-mouse").click(function(){
		//console.log("kk");
		if($("#enable-mouse").is(':checked')){
			CURSOR.open();
			localStorage.setItem('mouse',true);
		}else{
			CURSOR.close();
			localStorage.setItem('mouse',false);
		}
	});
});
